home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9551 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: news.umbc.edu!not-for-mail
  2. From: schlein@umbc.edu (Jonas J. Schlein)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: big problem with a very small program:please help me!
  5. Date: 11 Mar 1996 14:03:29 -0500
  6. Organization: University of Maryland Baltimore County
  7. Message-ID: <4i1te1$184@umbc9.umbc.edu>
  8. References: <4hqc8p$njh@aldebaran.sct.fr>
  9. NNTP-Posting-Host: umbc9.umbc.edu
  10. NNTP-Posting-User: schlein
  11.  
  12. Marc Escalier <escali_m@worldnet.net> wrote:
  13. |> #include <stdio.h>
  14. |> #include <math.h>
  15. |> 
  16. |> main()
  17. |> {
  18. |> float i;
  19. |> 
  20. |> i=5.25;
  21. |> printf("i is real:l%f\n",i);   /* display 5.25000000000000... ok! */
  22. |> printf("i is integer%d\n",i);  /* display 0  what does that mean ?!?*/
  23.  
  24. But 'i' is not an integer. That should be answer enough. Simply lying to 
  25. printf() won't make anything magical happen except for undefined results.
  26. You can however place an explicit cast like so:
  27.  
  28. printf ("i is integer: %d\n", (int) i);
  29.  
  30. |> return(0);
  31. |> }
  32. -- 
  33. "If it wasn't for C, we would be using BASI, PASAL, and OBOL."
  34.  
  35. Jonas J. Schlein  (schlein@gl.umbc.edu)
  36.